package com.wyc.apiPassenger.controller;

import com.wyc.apiPassenger.service.OrderService;
import com.wyc.internalCommon.request.OrderInfo;
import com.wyc.internalCommon.result.ApiResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RequestMapping("/order")
@RestController
public class OrderController {

    @Autowired
    private OrderService orderService;

    /**
     * 添加订单
     * @param orderInfo
     * @return
     */
    @PostMapping("/add")
    public ApiResult<OrderInfo> add(@RequestBody OrderInfo orderInfo){
        return orderService.add(orderInfo);
    }

    /**
     * 取消订单
     * @param orderId
     * @param identity 取消人的身份标识（1.乘客 2.司机3.平台）
     * @return
     */
    @PostMapping("/cancel")
    public ApiResult cancelOrder(@RequestParam("orderId") Long orderId, @RequestParam("identity") String identity){
        return orderService.cancelOrder(orderId,identity);
    }


}
